package com.clement.spring.study.config;

import org.springframework.context.MessageSource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.ImportResource;
import org.springframework.context.annotation.Primary;
import org.springframework.context.support.ResourceBundleMessageSource;

/**
 * Created by Clement on 2017/2/27.
 */
@Configuration
@ImportResource("classpath:META-INF/spring/message-source.xml")
public class MessageConfig {

    @Bean
    @Primary
    public MessageSource messageSource() {
        ResourceBundleMessageSource resourceBundleMessageSource = new ResourceBundleMessageSource();
        resourceBundleMessageSource.setBasenames("message/exceptions", "message/format");
        return resourceBundleMessageSource;
    }
}
